/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package presentation;

import formatters.EditFormatter;
import formatters.Formatter;
import formatters.InputFormatter;
import formatters.ViewFormatter;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.TreeMap;

/**
 *
 * @author Alejandro
 */
public class LinkElement extends PresentationElement {
    public class Pair<PresentationElement, Boolean> {
        public PresentationElement first;
        public Boolean second;
        public Pair() {}
    }
    public List<Pair> externals;
    public static final String ADD_EXTERNAL = "add-external";
    public static final String GET_EXTERNALS = "get-externals";

    public LinkElement() {
        super();
        externals = new LinkedList<Pair>();
    }

    @Override
    public void setParam(String param, Object value) {
        if (param.equals(ADD_EXTERNAL)) {
            List<Object> list = (List<Object>) value;
            Pair p = new Pair();
            p.first = (PresentationElement) list.get(0);
            p.second = (Boolean) list.get(1);
            externals.add(p);
        }
    }

    @Override
    public Object getParam(String param) {
        if (param.equals(GET_EXTERNALS)) {
            return externals;
        }
        return null;
    }

    @Override
    public void acceptView(Formatter f) {
        ViewFormatter vf = (ViewFormatter) f;
        vf.formatLink(this);
    }

    @Override
    public void acceptEdit(Formatter f) {
        EditFormatter ef = (EditFormatter) f;
        ef.formatLink(this);
    }

    @Override
    public void acceptInput(Formatter f) {
        InputFormatter fi = (InputFormatter) f;
        fi.formatLink(this);
    }

}
